package org.example.model;

public class Result {
    private Integer code;
    private String message;
    private Object data;

    private enum MessageStatus {
        success, fail
    }

    public static Result buildSuccess(Object data) {
        Result result = new Result();
        result.setCode(1);
        result.setMessage(MessageStatus.success.toString());
        result.setData(data);
        return result;
    }

    public static Result buildSuccess(Object data, String msg) {
        Result result = buildSuccess(data);
        result.setMessage(msg);
        return result;
    }

    public static Result buildSuccess(Object data, String msg, Integer code) {
        Result result = buildSuccess(data, msg);
        result.setCode(code);
        return result;
    }

    public static Result buildFail() {
        Result result = new Result();
        result.setCode(-1);
        result.setMessage(MessageStatus.fail.toString());
        return result;
    }

    public static Result buildFail(String msg) {
        Result result = buildFail();
        result.setMessage(msg);
        return result;
    }

    public static Result buildFail(String msg, Integer code) {
        Result result = buildFail(msg);
        result.setCode(code);
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}

